﻿using HZU.ZP.Data.Impl;
using HZU.ZP.Data.Interfaces;
using HZU.ZP.Domain.IService;
using HZU.ZP.Domain.Model;
using HZU.ZP.Domain.ServiceImpl.Mappers;
using System;
using System.Collections.Generic;
using System.Text;

namespace HZU.ZP.Domain.ServiceImpl.PCSvc
{
    public class NoticeService:INoticeService
    {
        private NoticeMapper _mapper = new NoticeMapper();
        private INoticeDao _sqlData;
        public NoticeService(INoticeDao sqlData)
        {
            _sqlData = sqlData;
        }

        public bool Add(Notice notice)
        {
            var noticeDao = _mapper.MapToDao(notice);
            _sqlData.Add(noticeDao);
            return true;
        }

        public bool Delete(int id)
        {
            _sqlData.Delete(id);
            return true;
        }

        public Notice GetById(int id)
        {
            return _mapper.MapToDomain(_sqlData.GetById(id));
        }

        public int GetCount()
        {
            return _sqlData.GetCount();
        }

        public IList<Notice> GetList(int pageIndex)
        {
            return _mapper.MapToDomainList(_sqlData.GetList(pageIndex));
        }

        public bool Update(Notice notice)
        {
            var noticeDao = _mapper.MapToDao(notice);
            _sqlData.Update(noticeDao);
            return true;
        }
    }
}
